﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 中介者模式.Mediator
{
    /// <summary>
    /// 中介者
    /// </summary>
    public  class BaseMediator
    {
        private List<BaseCharacter> _baseCharacters = new List<BaseCharacter>();
        public string Name { get; set; }


        public void AddCharacter(BaseCharacter baseCharacter)
        {
            this._baseCharacters.Add(baseCharacter);
        }

        /// <summary>
        /// 中介者发消息功能（相当于群）
        /// </summary>
        /// <param name="message"></param>
        /// <param name="characterFrom"></param>
        public void SendMessage(string message, BaseCharacter characterFrom) {

            Console.WriteLine("{0}Send:{1}", characterFrom.Name, message);

            foreach (var item in _baseCharacters)
            {
                item.GetMessage(message, characterFrom);
            }
        }






    }
}
